$def with (category, patlist)

<h1>Pattern Management</h1>
<div id="add-pattern">
  <label for="pattern">Pattern:</label>
  <input type="text" id="pattern" />
  <span>Be careful to set the pattern for crawler, YOU KNOW IT.</span>
  <br />
  <label for="category">Category:</label>
  <select id="category">
    <option value="0"></option>
    $for cate in category:
        <option value="$cate.cid">$cate.name</option>
  </select>
  <br />
  <label for="name">Description:</label>
  <textarea row="2" cols="30" id="patname"></textarea>
  <br />
  <input type="button" value="add" id="add-pattern-btn"/>
</div>

<div id="pattern-result" class="result"></div>

<div id="pattern-list">
  $:patlist
</div>

<script type="text/javascript">
$$("#add-pattern-btn").click(
function(){
    vname = $$("#patname").val();
    vpat  = $$("#pattern").val();
    vcate = $$("#category").val();
    if(vname && vpat && vcate)
    $$.post("/pat/add",
         {
         patname: vname,
         pattern: vpat,
         category: vcate
         },
         function(data){
            $$("#patname").val("");
            $$("#pattern").val("");
            $$("#category").val(0);
            $$("#pattern-list").html(data);
            $$("#pattern-result").html("Add pattern successfully: " + vpat );
         }
         );
});
</script>
